//
//  MallProductDetailCollectionViewCell.m
//  MeterMart
//
//  Created by ENERGY on 2018/10/10.
//  Copyright © 2018年 ENERGY. All rights reserved.
//

#import "MallProductDetailCollectionViewCell.h"

@interface MallProductDetailCollectionViewCell ()
@property (nonatomic, strong)UILabel * titleLab;
@property (nonatomic, strong)UILabel * bgLab;
@property (nonatomic, assign)int ifSelecte;//空或0的话为未选中，1为选中
@end

@implementation MallProductDetailCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.contentView.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.bgLab];
        [self.contentView addSubview:self.titleLab];
        __weak typeof (self)weakSelf = self;
        [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.bgLab.mas_left).mas_equalTo(10/WIDTH_6_SCALE);
            make.right.equalTo(weakSelf.bgLab.mas_right).mas_equalTo(-10/WIDTH_6_SCALE);
            make.centerY.equalTo(weakSelf.bgLab);
        }];
        [self.bgLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.left.right.equalTo(weakSelf.contentView);
            make.height.mas_equalTo(30/WIDTH_6_SCALE);
        }];
        
    }return self;
}
- (UILabel *)titleLab{
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] init];
        _titleLab.font = DEF_FontSize_12;
        _titleLab.text = @"---";
        _titleLab.textColor = [UIColor blackColor];
        _titleLab.textAlignment = NSTextAlignmentCenter;
        _titleLab.backgroundColor = [UIColor clearColor];
    }return _titleLab;
}
- (UILabel *)bgLab{
    if (!_bgLab) {
        _bgLab = [[UILabel alloc] init];
        _bgLab.layer.borderWidth = 1;
        _bgLab.layer.borderColor = [UIColor blackColor].CGColor;
        _bgLab.layer.cornerRadius = 6;
        _bgLab.layer.masksToBounds = YES;
    }return _bgLab;
}

- (void)setModel:(NSDictionary *)model{
    _model = model;
    if ([model[@"ifSelecte"] isEqualToString:@""] || [model[@"ifSelecte"] length] == 0 || model[@"ifSelecte"] == nil || [model[@"ifSelecte"] isEqualToString:@"0"]) {
        NSLog(@"空");
        self.titleLab.textColor = [UIColor blackColor];
        self.bgLab.layer.borderColor = [UIColor blackColor].CGColor;
    }else{
        NSLog(@"不空");
        self.titleLab.textColor = getColor(@"e92600");
        self.bgLab.layer.borderColor = getColor(@"e92600").CGColor;
    }
    self.titleLab.text = [NSString stringWithFormat:@"%@", model[@"guige"]];
}

@end
